package com.kevin.model.db;

import org.apache.commons.lang.StringUtils;

import com.kevin.util.ConfigProperties;

import lombok.Data;

@Data
public class DBSetInfo {
    protected String dbSetName; // 连接名自定义
    protected String dbUserName;
    protected String dbPassword;
    protected String dbUrl;
    protected String dbName; // mysql等用

    public static String getDbName() {
        String dbName = StringUtils.substringAfterLast(getDbUrl(), "/");
        if (dbName != null && dbName.contains("?")) {
            dbName = StringUtils.substringBefore(dbName, "?");
        }
        return dbName;
    }

    public static String getDbUrl() {
        return ConfigProperties.getString("db0_url");
    }

    public static String getDbUserName() {
        return ConfigProperties.getString("db0_username");
    }

    public static String getDbPassword() {
        return ConfigProperties.getString("db0_password");
    }

    public static void setDbUrl(String value) {
        ConfigProperties.setProperty("db0_url", value);
    }

    public static void setDbUserName(String value) {
        ConfigProperties.setProperty("db0_username", value);
    }

    public static void setDbPassword(String value) {
        ConfigProperties.setProperty("db0_password", value);
    }

    public static String getDbSetName() {
        return ConfigProperties.getString("db0_setname");
    }

    public static void setDbSetName(String value) {
        ConfigProperties.setProperty("db0_setname", value);
    }

}
